﻿using System.Data.Common;
using System.Linq.Expressions;

namespace Aore.Core.Repository.EFCore;

public interface IEfRepository<T> where T : class
{

  public T? GetById(object id);
  
  public IEnumerable<T> GetAll();
  
  public IEnumerable<T> Find(Expression<Func<T, bool>> predicate);
  
  Task<T?> GetByIdAsync(object id);

  Task<IEnumerable<T>> GetAllAsync();

  Task<IEnumerable<T>> FindAsync(Expression<Func<T, bool>> predicate);

  
  T Add(T entity);

  void AddRange(IEnumerable<T> entities);

  int SaveChanges();
  
  Task<T> AddAsync(T entity);

  Task AddRangeAsync(IEnumerable<T> entities);

  void Update(T entity);

  void Remove(T entity);

  void RemoveRange(IEnumerable<T> entities);

  Task<int> SaveChangesAsync();
  
  IEnumerable<T> FromSqlRaw(string sql, params DbParameter[] parameters);

  int ExecuteSqlRaw(string sql, params object[] parameters);
  
  IEnumerable<T> ExecuteStoredProcedure(string procName, params DbParameter[] parameters);

  DbDataReader ExecuteStoredProcedureReader(string procName, params DbParameter[] parameters);
  
  Task<IEnumerable<T>> FromSqlRawAsync(string sql, params DbParameter[] parameters);

  Task<int> ExecuteSqlRawAsync(string sql, params object[] parameters);
  
  Task<IEnumerable<T>> ExecuteStoredProcedureAsync(string procName, params DbParameter[] parameters);

  Task<DbDataReader> ExecuteStoredProcedureReaderAsync(string procName, params DbParameter[] parameters);
}